package lab03.test04;

import java.io.*;

/**
 * Created by 14394 on 2017/11/17.
 */
public class Test {
    public static void main(String[] args) {
        File file=new File("F:\\dev\\test.txt");
//        try {
//            file.createNewFile();
//
//        } catch (IOException e) {
//            e.printStackTrace();
//        }

        BufferedInputStream buf=null;
        InputStream inputStream=null;
        BufferedOutputStream bufo=null;
        OutputStream opts=null;
        try {
            inputStream=new FileInputStream(file);
            buf=new BufferedInputStream(inputStream);
            int data;
            while ((data=buf.read())!=-1){
                File file1=new File("D:\\dev\\MyTest.txt");
                opts=new FileOutputStream(file);
                bufo=new BufferedOutputStream(opts);
                System.out.println("run");
                bufo.write(data);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (buf!=null){
                try {
                    buf.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (bufo!=null){
                try {
                    bufo.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (opts!=null){
                try {
                    opts.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (bufo!=null){
                try {
                    bufo.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
